<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是uboot——uboot移植的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV09-02-uboot-03-uboot移植">
<meta property="og:url" content="https://sumumm.github.io/post/9d24e334.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是uboot——uboot移植的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821092709222.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821111803513.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821113347024.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821120100177.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821121614931.png">
<meta property="article:published_time" content="2023-07-07T11:34:11.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.001Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV09-uboot与linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821092709222.png">


<link rel="canonical" href="https://sumumm.github.io/post/9d24e334.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/9d24e334.html","path":"post/9d24e334.html","title":"LV09-02-uboot-03-uboot移植"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV09-02-uboot-03-uboot移植 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E6%96%87%E4%BB%B6%E5%87%86%E5%A4%87"><span class="nav-text">一、文件准备</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-u-boot%E6%BA%90%E7%A0%81"><span class="nav-text">1. u-boot源码</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96%E9%80%94%E5%BE%84"><span class="nav-text">1.1 源码获取途径</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E8%8E%B7%E5%8F%96%E6%BA%90%E7%A0%81%E6%96%87%E4%BB%B6"><span class="nav-text">1.2 获取源码文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-%E6%8B%B7%E8%B4%9D%E8%A7%A3%E5%8E%8B"><span class="nav-text">1.3 拷贝解压</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%A7%BB%E6%A4%8D%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">2. 移植相关文件</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E7%A7%BB%E6%A4%8D%E8%BF%87%E7%A8%8B"><span class="nav-text">二、移植过程</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E6%8C%87%E5%AE%9A%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7"><span class="nav-text">1. 指定交叉编译工具</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%B7%BB%E5%8A%A0Board%E4%BF%A1%E6%81%AF"><span class="nav-text">2. 添加Board信息</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E5%87%86%E5%A4%87%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">2.1 准备相关文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BF%AE%E6%94%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">2.2 修改相关文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-3-%E7%BC%96%E8%AF%91u-boot"><span class="nav-text">2.3 编译u-boot</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E6%B7%BB%E5%8A%A0%E4%B8%89%E6%98%9F%E5%8A%A0%E5%AF%86%E5%BC%95%E5%AF%BC%E6%96%B9%E5%BC%8F"><span class="nav-text">3. 添加三星加密引导方式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E5%87%86%E5%A4%87%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">3.1 准备相关文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BF%AE%E6%94%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">3.2 修改相关文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-3-%E7%BC%96%E5%86%99%E7%BC%96%E8%AF%91%E8%84%9A%E6%9C%AC"><span class="nav-text">3.3 编写编译脚本</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-4-%E6%B7%BB%E5%8A%A0%E8%B0%83%E8%AF%95%E4%BB%A3%E7%A0%81"><span class="nav-text">3.4 添加调试代码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-5-%E7%BC%96%E8%AF%91u-boot"><span class="nav-text">3.5 编译u-boot</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E4%B8%B2%E5%8F%A3%E7%A7%BB%E6%A4%8D"><span class="nav-text">4. 串口移植</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#4-1-%E4%BF%AE%E6%94%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">4.1 修改相关文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-2-%E7%BC%96%E8%AF%91u-boot"><span class="nav-text">4.2 编译u-boot</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E7%BD%91%E5%8D%A1%E7%A7%BB%E6%A4%8D"><span class="nav-text">5. 网卡移植</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#5-1-%E4%BF%AE%E6%94%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">5.1 修改相关文件</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-1-%E7%BD%91%E7%BB%9C%E5%88%9D%E5%A7%8B%E5%8C%96"><span class="nav-text">5.1.1 网络初始化</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#5-1-2-%E7%BD%91%E7%BB%9C%E9%85%8D%E7%BD%AE%E4%BF%AE%E6%94%B9"><span class="nav-text">5.1.2 网络配置修改</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-2-%E7%BC%96%E8%AF%91u-boot"><span class="nav-text">5.2 编译u-boot</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-eMMC%E7%A7%BB%E6%A4%8D"><span class="nav-text">6. eMMC移植</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-%E6%96%87%E4%BB%B6%E5%87%86%E5%A4%87"><span class="nav-text">6.1 文件准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-%E4%BF%AE%E6%94%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">6.2 修改相关文件</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#6-2-1-eMMC%E5%88%9D%E5%A7%8B%E5%8C%96"><span class="nav-text">6.2.1 eMMC初始化</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-2-2-%E6%B7%BB%E5%8A%A0eMMC%E5%91%BD%E4%BB%A4"><span class="nav-text">6.2.2 添加eMMC命令</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#6-2-3-eMMC%E9%85%8D%E7%BD%AE"><span class="nav-text">6.2.3 eMMC配置</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-3-%E7%BC%96%E8%AF%91u-boot"><span class="nav-text">6.3 编译u-boot</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#7-%E7%94%B5%E6%BA%90%E7%AE%A1%E7%90%86%E7%A7%BB%E6%A4%8D"><span class="nav-text">7. 电源管理移植</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#7-1-%E6%96%87%E4%BB%B6%E5%87%86%E5%A4%87"><span class="nav-text">7.1 文件准备</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-2-%E4%BF%AE%E6%94%B9%E7%9B%B8%E5%85%B3%E6%96%87%E4%BB%B6"><span class="nav-text">7.2 修改相关文件</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-3-%E7%BC%96%E8%AF%91u-boot"><span class="nav-text">7.3 编译u-boot</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E5%85%B6%E4%BB%96%E4%BF%AE%E6%94%B9"><span class="nav-text">三、其他修改</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%BC%96%E8%AF%91%E8%84%9A%E6%9C%AC"><span class="nav-text">1. 编译脚本</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%9D%BF%E5%AD%90%E5%90%8D%E7%A7%B0"><span class="nav-text">2. 板子名称</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/9d24e334.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV09-02-uboot-03-uboot移植 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV09-02-uboot-03-uboot移植
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-07-07 19:34:11" itemprop="dateCreated datePublished" datetime="2023-07-07T19:34:11+08:00">2023-07-07</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/" itemprop="url" rel="index"><span itemprop="name">01HQ课程体系</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/" itemprop="url" rel="index"><span itemprop="name">LV09-uboot与linux</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>7.3k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>27 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是uboot——uboot移植的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">SecureCRT</td>        <td align="left">Version 8.7.2 (x64 build 2214)   -   正式版-2020年5月14日</td>      </tr>    <tr>        <td align="center" width=150>Linux开发板</td>        <td align="left">华清远见 底板: FS4412_DEV_V5 核心板: FS4412 V2</td>      </tr>    <tr>        <td align="center" width=150>u-boot</td>        <td align="left">2013.01</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr><td align="center">参考方向</td><td align="center">参考原文</td></tr>    <tr><td align="left">u-boot移植</td><td align="left">实验6 u-boot-2013.01移植</td></tr>    <tr><td align="left">驱动开发指南</td><td align="left"><a href="http://47.111.11.73/docs/boards/arm-linux/zdyz-i.mx6ull.html#i-mx6ull-linux" target="_blank">i.MX6ULL Linux阿尔法开发板资料 <i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left">uboot官网</td><td align="left"><a href="https://www.denx.de/wiki/U-Boot" target="_blank">U-Boot | DENX <i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr><td align="center">文件</td><td align="center">下载链接</td></tr>    <tr><td align="left">u-boot-2013.01移植相关文件.rar</td><td align="left"><a href="https://wwz.lanzouy.com/iIEba09xou0h" target="_blank">u-boot-2013.01移植相关文件 <i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>



<h1 id="一、文件准备"><a href="#一、文件准备" class="headerlink" title="一、文件准备"></a><font size=3>一、文件准备</font></h1><h2 id="1-u-boot源码"><a href="#1-u-boot源码" class="headerlink" title="1. u-boot源码"></a><font size=3>1. <code>u-boot</code>源码</font></h2><h3 id="1-1-源码获取途径"><a href="#1-1-源码获取途径" class="headerlink" title="1.1 源码获取途径"></a><font size=3>1.1 源码获取途径</font></h3><p>关于<code>u-boot</code>的官方源码我们可以从这里获取：<a target="_blank" rel="noopener" href="https://u-boot.readthedocs.io/en/latest/build/source.html">Obtaining the source <i class="fa fa-external-link-alt"></i> </a>。从官网文档可以看到我们可以有多种下载源码的途径：</p>
<ul>
<li><code>Github</code></li>
</ul>
<p>仓库地址为：<a target="_blank" rel="noopener" href="https://github.com/u-boot/u-boot">u-boot&#x2F;u-boot: “Das U-Boot” Source Tree (github.com)  <i class="fa fa-external-link-alt"></i> </a></p>
<p>各版本地址为：<a target="_blank" rel="noopener" href="https://github.com/u-boot/u-boot/tags">Tags · u-boot&#x2F;u-boot (github.com) <i class="fa fa-external-link-alt"></i> </a></p>
<p>我们可以通过以下命令来获取最新版本：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone https://github.com/u-boot/u-boot</span><br></pre></td></tr></table></figure>

<ul>
<li><code>Gitlab</code></li>
</ul>
<p>仓库地址为：<a target="_blank" rel="noopener" href="https://source.denx.de/u-boot/u-boot">U-Boot &#x2F; U-Boot · GitLab (denx.de)  <i class="fa fa-external-link-alt"></i></a></p>
<p>各版本地址为：<a target="_blank" rel="noopener" href="https://source.denx.de/u-boot/u-boot/-/tags">Tags · U-Boot &#x2F; U-Boot · GitLab (denx.de)  <i class="fa fa-external-link-alt"></i></a></p>
<p>我们可以通过以下命令获取最新版本：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone https://source.denx.de/u-boot/u-boot.git</span><br></pre></td></tr></table></figure>

<ul>
<li><code>ftp</code></li>
</ul>
<p>这种方式在官网文档上我没看到，不过也是可以通过<code>ftp</code>服务器来下载我们需要的版本的，我一般都是在这里下载的，毕竟<code>Github</code>有时候也没那么好进。通过<code>ftp</code>服务器下载的话，下载下来的就直接是压缩包了，我是用的华清远见的<code>FS4412</code>开发板，所以这里选择相配套的版本，也就是<code>u-boot-2013.01.tar.bz2</code>这个压缩包。</p>
<p>各版本下载地址：<a target="_blank" rel="noopener" href="https://ftp.denx.de/pub/u-boot/">Index of &#x2F;pub&#x2F;u-boot&#x2F; (denx.de)  <i class="fa fa-external-link-alt"></i></a></p>
<h3 id="1-2-获取源码文件"><a href="#1-2-获取源码文件" class="headerlink" title="1.2 获取源码文件"></a><font size=3>1.2 获取源码文件</font></h3><p>我下载的是<code>u-boot-2013.01.tar.bz2</code>这个压缩包并将其存放于<code>ubuntu</code>下的共享文件夹下，路径为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/mnt/hgfs/Sharedfiles/test</span><br></pre></td></tr></table></figure>

<h3 id="1-3-拷贝解压"><a href="#1-3-拷贝解压" class="headerlink" title="1.3 拷贝解压"></a><font size=3>1.3 拷贝解压</font></h3><p>然后我们可以将这个源码文件拷贝解压到<code>ubuntu</code>中，方便后边编译，我们可以在终端执行以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cp /mnt/hgfs/Sharedfiles/test/u-boot-2013.01.tar.bz2 ~/6temp/    # 拷贝压缩包</span><br><span class="line">cd ~/6temp/</span><br><span class="line">tar -xvf u-boot-2013.01.tar.bz2                                  # 解压</span><br></pre></td></tr></table></figure>

<p>然后我们可以得到下边这些文件（通过<code>ls</code>命令查看）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">api         config.mk  drivers    include      mkconfig  rules.mk</span><br><span class="line">arch        COPYING    dts        lib          nand_spl  snapshot.commit</span><br><span class="line">board       CREDITS    examples   MAINTAINERS  net       spl</span><br><span class="line">boards.cfg  disk       fs         MAKEALL      post      test</span><br><span class="line">common      doc        helper.mk  Makefile     README    tools</span><br></pre></td></tr></table></figure>

<details class="folding-tag" blue><summary> 点击查看部分文件说明 </summary>
              <div class='content'>
              <ul><li><strong>平台相关</strong></li></ul><p>即与<code>CPU</code>架构或开发板硬件相关的源码，硬件的改动对应的代码也需要进行修改。</p><table>    <tr><td align="left">arch </td><td align="left">与CPU架构相关的源代码</td></tr>    <tr><td align="left">board</td><td align="left">与开发板相关的源代码，包含各种官方评估板对应的源码</td></tr></table><ul><li><strong>平台无关</strong></li></ul><table>    <tr><td align="left">api</td><td align="left">应用接口，一些与硬件无关的API函数</td></tr>    <tr><td align="left">common</td><td align="left">uboot命令源码</td></tr>    <tr><td align="left">disk</td><td align="left">对磁盘设备的支持，主要是磁盘分区相关代码</td></tr>    <tr><td align="left">drivers</td><td align="left">设备驱动源码</td></tr>    <tr><td align="left">fs</td><td align="left">对文件系统的支持</td></tr>    <tr><td align="left">include</td><td align="left">头文件</td></tr>    <tr><td align="left">lib</td><td align="left">库文件</td></tr>    <tr><td align="left">net</td><td align="left">对网络协议的支持</td></tr>    <tr><td align="left">post</td><td align="left">上电自检程序</td></tr>    <tr><td align="left">tools</td><td align="left">一些工具文件夹，有些工具编译后才能生成，比如后边会用到的mkimage工具</td></tr></table><p>还有一些其他的文件，这里就不再写了。</p>
              </div>
            </details>

<h2 id="2-移植相关文件"><a href="#2-移植相关文件" class="headerlink" title="2. 移植相关文件"></a><font size=3>2. 移植相关文件</font></h2><p>移植相关文件是老师已经写好了的，后边按教程使用即可，可以在这里下载：<a target="_blank" rel="noopener" href="https://wwz.lanzouy.com/iIEba09xou0h">u-boot-2013.01移植相关文件  <i class="fa fa-external-link-alt"></i></a></p>
<p>下载完毕后，存放于<code>ubuntu</code>的共享文件夹中：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/mnt/hgfs/Sharedfiles/test</span><br></pre></td></tr></table></figure>

<p>我们可直接在<code>windows</code>下将压缩文件解压，我们将得到下边这些文件：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821092709222.png" alt="image-20220821092709222" style="zoom:33%;" />

<h1 id="二、移植过程"><a href="#二、移植过程" class="headerlink" title="二、移植过程"></a><font size=3>二、移植过程</font></h1><p>首先我们要进入<code>uboot</code>源码目录，后边所有的命令都在源码的顶层目录下进行：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cd ~/6temp/u-boot-2013.01</span><br></pre></td></tr></table></figure>

<h2 id="1-指定交叉编译工具"><a href="#1-指定交叉编译工具" class="headerlink" title="1. 指定交叉编译工具"></a><font size=3>1. 指定交叉编译工具</font></h2><p><code>uboot</code>源码并不知道我们使用的处理器架构及交叉编译工具是什么，这里我们需要自己在<code>Makefile</code>中指定，我们通过下边的命令打开顶层<code>Makefile</code>文件：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim Makefile</span><br></pre></td></tr></table></figure>

<p>找到下边的语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># set default to nothing for native builds</span></span><br><span class="line"><span class="keyword">ifeq</span> (<span class="variable">$(HOSTARCH)</span>,<span class="variable">$(ARCH)</span>)</span><br><span class="line">CROSS_COMPILE ?=</span><br><span class="line"><span class="keyword">endif</span></span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># set default to nothing for native builds</span></span><br><span class="line"><span class="keyword">ifeq</span> (arm,arm)</span><br><span class="line">CROSS_COMPILE ?= arm-none-linux-gnueabi-</span><br><span class="line"><span class="keyword">endif</span></span><br></pre></td></tr></table></figure>

<p>【注意】<code>arm-none-linux-gnueabi-</code>后边不要有多余的空格。</p>
<p>但是其实还有一种方式，可以避免修改原来的<code>makefile</code>文件，那就是在使用<code>make</code>命令的时候指定两个参数：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- &lt;command&gt;</span><br></pre></td></tr></table></figure>

<h2 id="2-添加Board信息"><a href="#2-添加Board信息" class="headerlink" title="2. 添加Board信息"></a><font size=3>2. 添加<code>Board</code>信息</font></h2><p><code>uboot</code>源码并华清远见的<code>fs4412</code>开发板，所以需要从源码支持的开发板中找一个硬 件与我们使用的开发板最类似的，在其基础上进行修改，这里参考的是<code>samsung</code>公司的<code>origen</code>评估板，这个评估板使用的处理器就是<code>fs4412</code>。</p>
<h3 id="2-1-准备相关文件"><a href="#2-1-准备相关文件" class="headerlink" title="2.1 准备相关文件"></a><font size=3>2.1 准备相关文件</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cp -rf board/samsung/origen/  board/samsung/fs4412               # 拷贝相关文件夹</span><br><span class="line">mv board/samsung/fs4412/origen.c board/samsung/fs4412/fs4412.c   # 重命名为fs4412</span><br><span class="line">cp include/configs/origen.h include/configs/fs4412.h             # 拷贝相关头文件</span><br></pre></td></tr></table></figure>

<h3 id="2-2-修改相关文件"><a href="#2-2-修改相关文件" class="headerlink" title="2.2 修改相关文件"></a><font size=3>2.2 修改相关文件</font></h3><p>具体修改了哪些文件，及修改前后对比可以看我的<code>github</code>仓库：<a target="_blank" rel="noopener" href="https://github.com/sumumm/u-boot/commit/e4e483e57d55de786560a7069e8d820493cdd6a0">feat:修改fs4412相关支持文件 · sumumm&#x2F;u-boot@e4e483e (github.com)</a>。修改过程如下：</p>
<ul>
<li>修改<code>board/samsung/fs4412/Makefile</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ifndef CONFIG_SPL_BUILD</span><br><span class="line">COBJS	+= origen.o</span><br><span class="line">endif</span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">ifndef CONFIG_SPL_BUILD</span><br><span class="line">COBJS	+= fs4412.o</span><br><span class="line">endif</span><br></pre></td></tr></table></figure>

<ul>
<li><code>include/configs/fs4412.h</code></li>
</ul>
<p>（1）我们找到如下语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_SYS_PROMPT		<span class="string">&quot;ORIGEN # &quot;</span></span></span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_SYS_PROMPT		<span class="string">&quot;fs4412 # &quot;</span></span></span><br></pre></td></tr></table></figure>

<p>（2）再找到下边语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_IDENT_STRING		<span class="string">&quot; for ORIGEN&quot;</span></span></span><br></pre></td></tr></table></figure>

<p>将其修改为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_IDENT_STRING		<span class="string">&quot; for fs4412&quot;</span></span></span><br></pre></td></tr></table></figure>

<ul>
<li>修改<code>boards.cfg</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">origen			     arm	 armv7	     origen		 samsung	exynos</span><br></pre></td></tr></table></figure>

<p>然后在其下一行添加如下内容（FS4412的相关信息）：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">fs4412			     arm	 armv7	     fs4412		 samsung	exynos</span><br></pre></td></tr></table></figure>



<p>至此，我们在<code>uboot</code>源码中给我们的板子添加了信息，此时源码就支持我们现在使用的开发板了。</p>
<h3 id="2-3-编译u-boot"><a href="#2-3-编译u-boot" class="headerlink" title="2.3 编译u-boot"></a><font size=3>2.3 编译<code>u-boot</code></font></h3><p>接下来我们就可以编译我们刚才修改过的<code>u-boot</code>了，我们在顶层源码目录下执行：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- fs4412_config # 指定使用 fs4412 配置信息</span><br><span class="line">make V=1 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- j4        # 开始编译整个 u-boot</span><br></pre></td></tr></table></figure>

<ul>
<li><code>V=1</code>表示显示详细编译过程。</li>
<li><code>j4</code>表示使用编译平台的<code>4</code>个核同时进行多线程编译。</li>
</ul>
<h2 id="3-添加三星加密引导方式"><a href="#3-添加三星加密引导方式" class="headerlink" title="3. 添加三星加密引导方式"></a><font size=3>3. 添加三星加密引导方式</font></h2><p>考虑芯片启动的安全性，<code>Exynos4412</code>需要三星提供的初始引导加密后我们移植的<code>u-boot</code>才能被引导运行，所以我们需要在<code>uboot</code>源码中添加三星提供的加密处理相关代码。</p>
<h3 id="3-1-准备相关文件"><a href="#3-1-准备相关文件" class="headerlink" title="3.1 准备相关文件"></a><font size=3>3.1 准备相关文件</font></h3><p>主要是拷贝<code>CodeSign4SecureBoot</code>和<code>sdfuse_q</code>两个目录及其目录下的所有文件到<code>u-boot</code>源码顶层目录下，我们在终端执行以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/CodeSign4SecureBoot/ .</span><br><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/sdfuse_q/ .</span><br></pre></td></tr></table></figure>

<p>【注意】这之后不要执行<code>make clean</code>或<code>make distclean</code>，这会将加密文件清除。</p>
<h3 id="3-2-修改相关文件"><a href="#3-2-修改相关文件" class="headerlink" title="3.2 修改相关文件"></a><font size=3>3.2 修改相关文件</font></h3><p>具体修改了哪些文件，及修改前后对比可以看我的<code>github</code>仓库：<a target="_blank" rel="noopener" href="https://github.com/sumumm/u-boot/commit/102e8fab7b7a265cf76ae7c573b052f8bfbf0818">feat:添加三星加密引导方式相关文件 · sumumm&#x2F;u-boot@102e8fa (github.com)</a></p>
<ul>
<li>修改<code>Makefile</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable">$(obj)</span>u-boot.bin:	<span class="variable">$(obj)</span>u-boot</span><br><span class="line">		<span class="variable">$(OBJCOPY)</span> $&#123;OBJCFLAGS&#125; -O binary <span class="variable">$&lt;</span> <span class="variable">$@</span></span><br><span class="line">		<span class="variable">$(BOARD_SIZE_CHECK)</span></span><br></pre></td></tr></table></figure>

<p>修改为如下内容（紧随其后添加一些与加密引导方式相关的编译命令）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">$</span><span class="language-bash">(obj)u-boot.bin:	$(obj)u-boot</span></span><br><span class="line"><span class="meta prompt_">		$</span><span class="language-bash">(OBJCOPY) <span class="variable">$&#123;OBJCFLAGS&#125;</span> -O binary $&lt; <span class="variable">$@</span></span></span><br><span class="line"><span class="meta prompt_">		$</span><span class="language-bash">(BOARD_SIZE_CHECK)</span></span><br><span class="line"><span class="meta prompt_">		@#</span><span class="language-bash">./mkuboot</span></span><br><span class="line">		@split -b 14336 u-boot.bin bl2</span><br><span class="line">		@+make -C sdfuse_q/</span><br><span class="line"><span class="meta prompt_">		@#</span><span class="language-bash"><span class="built_in">cp</span> u-boot.bin u-boot-4212.bin</span></span><br><span class="line"><span class="meta prompt_">		@#</span><span class="language-bash"><span class="built_in">cp</span> u-boot.bin u-boot-4412.bin</span></span><br><span class="line"><span class="meta prompt_">		@#</span><span class="language-bash">./sdfuse_q/add_sign</span></span><br><span class="line">		@./sdfuse_q/chksum</span><br><span class="line">		@./sdfuse_q/add_padding</span><br><span class="line">		@rm bl2a*</span><br><span class="line">		@echo</span><br></pre></td></tr></table></figure>

<p>【注意】若是不修改的话，编译的时候可能会报错。</p>
<h3 id="3-3-编写编译脚本"><a href="#3-3-编写编译脚本" class="headerlink" title="3.3 编写编译脚本"></a><font size=3>3.3 编写编译脚本</font></h3><p>添加了三星加密引导方式后，编译完<code>u-boot</code>后，我们还需要进行一些列的操作，所以这里边写一个编译脚本，方便编译。</p>
<details class="folding-tag" blue><summary> 点击查看编译脚本详细内容 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/sh</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">=====================================================</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Copyright © hk. 2022-2025. All rights reserved.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">File name: qidaink_make.sh</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Author   : qidaink</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Date     : 2022-08-19</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Version  :</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Description:</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Others   : CROSS_COMPILE -- 当前使用的编译器</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Log      :</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">======================================================</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">===================相关参数定义=========================</span></span><br><span class="line">CPU_JOB_NUM=$(grep processor /proc/cpuinfo | awk &#x27;&#123;field=$NF&#125;;END&#123;print field+1&#125;&#x27;) # 参与编译的内核数量获取</span><br><span class="line">BOARD_NAME=&quot;fs4412&quot;                                         # 硬件平台,后续以 origen 评估板为模板</span><br><span class="line">MAKE_PARAM=&quot;ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-&quot; # 交叉编译器</span><br><span class="line">sec_path=&quot;CodeSign4SecureBoot/&quot;                          # 三星加密引导方式路径</span><br><span class="line">ROOT_DIR=$(pwd)                                          # 顶层(当前)目录路径</span><br><span class="line">CUR_DIR=$&#123;ROOT_DIR##*/&#125;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">===================配置与编译===========================</span></span><br><span class="line">case &quot;$1&quot; in</span><br><span class="line">	clean)</span><br><span class="line">        # 清除编译过程中产生的中间文件而不清除加密文件</span><br><span class="line">		echo</span><br><span class="line">        echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;33m[INFO ]make $&#123;MAKE_PARAM&#125; clean                 \033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;33m************************************************\033[0m&quot; </span><br><span class="line">        make $&#123;MAKE_PARAM&#125; mrproper</span><br><span class="line">        ;;</span><br><span class="line">	*)</span><br><span class="line">        # 判断加密引导方式文件目录是否存在</span><br><span class="line">        if [ ! -d $&#123;sec_path&#125; ]</span><br><span class="line">            then</span><br><span class="line">				echo</span><br><span class="line">                echo &quot;\033[1;31m************************************************\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;31m[ERROR]please get the CodeSign4SecureBoot first!\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;31m************************************************\033[0m&quot;</span><br><span class="line">                return</span><br><span class="line">            fi</span><br><span class="line"></span><br><span class="line">        # 指定当前使用的硬件平台 make &lt;BOARD_NAME&gt;_config</span><br><span class="line">		echo</span><br><span class="line">        echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;33m[INFO ]Configuring the Project ...              \033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">        make $&#123;MAKE_PARAM&#125; $&#123;BOARD_NAME&#125;_config</span><br><span class="line"></span><br><span class="line">        # 开始编译整个 uboot</span><br><span class="line">		echo</span><br><span class="line">        echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;33m[INFO ]Building project in progress ...         \033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">        make V=1 $&#123;MAKE_PARAM&#125; -j$&#123;CPU_JOB_NUM&#125;</span><br><span class="line"></span><br><span class="line">        # 判断是否编译成功</span><br><span class="line">        if [ ! -f checksum_bl2_14k.bin ]</span><br><span class="line">			then</span><br><span class="line">				echo</span><br><span class="line">				echo &quot;\033[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\033[0m&quot;</span><br><span class="line">				echo &quot;\033[1;31m[ERROR]There are some error(s) while building uboot, please use command make to check.\033[0m&quot;</span><br><span class="line">				echo &quot;\033[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\033[0m&quot;</span><br><span class="line">				exit 0</span><br><span class="line">			fi</span><br><span class="line">        # 三星加密引导方式相关操作，必须要有</span><br><span class="line">        cp -rf checksum_bl2_14k.bin $&#123;sec_path&#125;</span><br><span class="line">		cp -rf u-boot.bin $&#123;sec_path&#125;</span><br><span class="line">		rm checksum_bl2_14k.bin</span><br><span class="line"></span><br><span class="line">        cd $&#123;sec_path&#125;</span><br><span class="line">		cat E4412_N.bl1.SCP2G.bin bl2.bin all00_padding.bin u-boot.bin tzsw_SMDK4412_SCP_2GB.bin &gt; u-boot-fs4412.bin</span><br><span class="line">		mv u-boot-fs4412.bin $&#123;ROOT_DIR&#125;</span><br><span class="line">		</span><br><span class="line">		rm checksum_bl2_14k.bin</span><br><span class="line">		rm u-boot.bin</span><br><span class="line"></span><br><span class="line">        # 编译完成提示已经完成</span><br><span class="line">		echo</span><br><span class="line">        echo &quot;\033[1;32m************************************************\033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;32m[INFO ]The compilation is complete!!!\033[0m&quot;</span><br><span class="line">        echo &quot;\033[1;32m************************************************\033[0m&quot;</span><br><span class="line">		echo </span><br><span class="line">		;;</span><br><span class="line">esac</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<h3 id="3-4-添加调试代码"><a href="#3-4-添加调试代码" class="headerlink" title="3.4 添加调试代码"></a><font size=3>3.4 添加调试代码</font></h3><p>添加完三星加密引导方式后，应该就可以编译<code>u-boot</code>，然后在开发板中启动<code>u-boot</code>了，但是有一个问题，就是，对于这块开发板来说外设并不跟三星的<code>origen</code>评估板一样，我们无法判断到此为止的<code>u-boot</code>能否在开发板正常启动，这个时候我们就需要添加一段调试代码，可以在<code>u-boot</code>源码中添加一段使板子上的LED点亮的程序来指示我们的<code>u-boot</code>已经开始运行了。这一部分的修改也可以查看这里：<a target="_blank" rel="noopener" href="https://github.com/sumumm/u-boot/commit/6b8ce6461b9e5ac516b24049c565a0b01dc41c6c">feat:创建VScode工程并添加调试代码 · sumumm&#x2F;u-boot@6b8ce64 (github.com)</a></p>
<ul>
<li>修改<code>arch/arm/cpu/armv7/start.S</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">reset:</span><br><span class="line">	bl	save_boot_params</span><br><span class="line">	/*</span><br><span class="line">	 * set the cpu to SVC32 mode</span><br><span class="line">	 */</span><br><span class="line">	mrs	r0, cpsr</span><br><span class="line">	bic	r0, r0, #0x1f</span><br><span class="line">	orr	r0, r0, #0xd3</span><br><span class="line">	msr	cpsr,r0</span><br></pre></td></tr></table></figure>

<p>在<code>134</code>行（如果<code>u-boot</code>版本一样的话）也就是上边找到的语句的最后一行的下一行添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">/* 点亮 LED */</span><br><span class="line">ldr r0, =0x11000c40</span><br><span class="line">ldr r1, [r0]</span><br><span class="line">bic r1, r1, #0xf0000000</span><br><span class="line">orr r1, r1, #0x10000000</span><br><span class="line">str r1, [r0]</span><br><span class="line">ldr r0, =0x11000c44</span><br><span class="line">mov r1, #0xff</span><br><span class="line">str r1, [r0]</span><br></pre></td></tr></table></figure>



<h3 id="3-5-编译u-boot"><a href="#3-5-编译u-boot" class="headerlink" title="3.5 编译u-boot"></a><font size=3>3.5 编译<code>u-boot</code></font></h3><p>我们已经编写了<code>u-boot</code>编译脚本，所以这里直接通过脚本编译即可：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sudo chmod 777 qidaink_make.sh</span><br><span class="line">./qidaink_make.sh</span><br></pre></td></tr></table></figure>

<p>编译完成后，我们按照之前的镜像制作方式将移植后的<code>u-boot</code>下载到<code>SD</code>开中，然后开发板从<code>SD</code>卡启动，若移植正确的话，我们将看到一个<code>LED</code>被点亮，不出意外的话，会发现隔一段时间就会灭掉然后再亮，刚开始以为是移植失败，后来发现是因为<code>u-boot</code>默认打开了看门狗，而后边又没有正常喂狗，导致开发板复位了，所以这是正常现象。</p>
<h2 id="4-串口移植"><a href="#4-串口移植" class="headerlink" title="4. 串口移植"></a><font size=3>4. 串口移植</font></h2><p>前边我们会发现，即便移植<code>u-boot</code>完成了，但是依然不适配我们的开发板，我们还需要移植一下串口的驱动，详细的文件修改情况可以查看这里：<a target="_blank" rel="noopener" href="https://github.com/sumumm/u-boot/commit/6b8a6c528ac9fcf671f79131e746c2fe60535460">feat:修改串口驱动 · sumumm&#x2F;u-boot@6b8a6c5 (github.com)</a></p>
<h3 id="4-1-修改相关文件"><a href="#4-1-修改相关文件" class="headerlink" title="4.1 修改相关文件"></a><font size=3>4.1 修改相关文件</font></h3><p>对于串口的移植，我们只需要修改一个文件即可：<code>board/samsung/fs4412/lowlevel_init.S</code></p>
<ul>
<li>（1）初始化临时栈</li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">lowlevel_init:</span><br></pre></td></tr></table></figure>

<p>在该语句后边添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ldr  sp,=0x02060000</span><br></pre></td></tr></table></figure>

<ul>
<li>（2）关闭看门狗</li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">beq	wakeup_reset</span><br></pre></td></tr></table></figure>

<p>在该语句后边添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="keyword">if</span> 1</span></span><br><span class="line">	ldr r0, =0x1002330c</span><br><span class="line">	ldr r1, [r0]</span><br><span class="line">	orr r1, r1, #0x300</span><br><span class="line">	str r1, [r0]</span><br><span class="line">	ldr r0, =0x11000c08</span><br><span class="line">	ldr r1, =0x0</span><br><span class="line">	str r1, [r0]</span><br><span class="line">/* Clear  MASK_WDT_RESET_REQUEST  */</span><br><span class="line">	ldr r0, =0x1002040c</span><br><span class="line">	ldr r1, =0x00</span><br><span class="line">	str r1, [r0]</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">endif</span></span><br></pre></td></tr></table></figure>

<ul>
<li>（3）<code>UART</code>初始化</li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">uart_asm_init:</span><br><span class="line"></span><br><span class="line">	/* setup UART0-UART3 GPIOs (part1) */</span><br><span class="line">	mov	r0, r7</span><br><span class="line">	ldr	r1, =EXYNOS4_GPIO_A0_CON_VAL</span><br><span class="line">	str	r1, [r0, #EXYNOS4_GPIO_A0_CON_OFFSET]</span><br><span class="line">	ldr	r1, =EXYNOS4_GPIO_A1_CON_VAL</span><br><span class="line">	str	r1, [r0, #EXYNOS4_GPIO_A1_CON_OFFSET]</span><br></pre></td></tr></table></figure>

<p>在该部分语句最后一句后边添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">ldr	r0, =0x10030000</span><br><span class="line">ldr	r1, =0x666666</span><br><span class="line">ldr	r2, =CLK_SRC_PERIL0_OFFSET</span><br><span class="line">str	r1, [r0, r2]</span><br><span class="line">ldr	r1, =0x777777</span><br><span class="line">ldr	r2, =CLK_DIV_PERIL0_OFFSET</span><br><span class="line">str	r1, [r0, r2]</span><br></pre></td></tr></table></figure>

<ul>
<li>（4）注释<code>bl tzpc_init</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">bl uart_asm_init</span><br></pre></td></tr></table></figure>

<p>将其修改为以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="keyword">if</span> 0</span></span><br><span class="line">	bl tzpc_init</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">endif</span></span><br></pre></td></tr></table></figure>

<h3 id="4-2-编译u-boot"><a href="#4-2-编译u-boot" class="headerlink" title="4.2 编译u-boot"></a><font size=3>4.2 编译<code>u-boot</code></font></h3><p>我们直接通过编译脚本进行编译：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./qidaink_make.sh</span><br></pre></td></tr></table></figure>

<p>编译完成后将生成的<code>u-boot-fs4412.bin</code>制作成可在开发板运行的镜像，下载到<code>SD</code>卡进行测试，若有如下提示，则证明串口移植成功：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821111803513.png" alt="image-20220821111803513" style="zoom:33%;" />

<h2 id="5-网卡移植"><a href="#5-网卡移植" class="headerlink" title="5. 网卡移植"></a><font size=3>5. 网卡移植</font></h2><p>虽然可以通过终端输入命令，但此时的<code>u-boot</code>还不能使用<code>ping</code>、<code>tftp</code>等命令，原因在于命令都是操作网络的，而<code>u-boot</code>源码中网卡的相关配置与我们当前的板子不匹配，所以还要对网卡进行移植。详细的文件修改情况可以看这里：<a target="_blank" rel="noopener" href="https://github.com/sumumm/u-boot/commit/0165b21f74694d3295cf26a1eac1ec04d958ba2a">feat:修改网卡驱动 · sumumm&#x2F;u-boot@0165b21 (github.com)</a></p>
<h3 id="5-1-修改相关文件"><a href="#5-1-修改相关文件" class="headerlink" title="5.1 修改相关文件"></a><font size=3>5.1 修改相关文件</font></h3><h4 id="5-1-1-网络初始化"><a href="#5-1-1-网络初始化" class="headerlink" title="5.1.1 网络初始化"></a><font size=3>5.1.1 网络初始化</font></h4><ul>
<li>修改<code>board/samsung/fs4412/fs4412.c</code></li>
</ul>
<p>（1）我们找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">exynos4_gpio_part2</span> *<span class="title">gpio2</span>;</span></span><br></pre></td></tr></table></figure>

<p>在后边添加如下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span>  CONFIG_DRIVER_DM9000</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> EXYNOS4412_SROMC_BASE 0X12570000</span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_Tacs     (0x1) </span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_Tcos     (0x1) </span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_Tacc     (0x5) </span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_Tcoh     (0x1) </span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_Tah      (0xC) </span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_Tacp     (0x9)   </span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_PMC      (0x1)  </span></span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">exynos_sromc</span> &#123;</span></span><br><span class="line">	<span class="type">unsigned</span> <span class="type">int</span> bw;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">int</span> bc[<span class="number">6</span>];</span><br><span class="line">&#125;;</span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">exynos_config_sromc</span><span class="params">(u32 srom_bank, u32 srom_bw_conf, u32 srom_bc_conf)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">int</span> tmp;</span><br><span class="line">	<span class="class"><span class="keyword">struct</span> <span class="title">exynos_sromc</span> *<span class="title">srom</span> =</span> (<span class="keyword">struct</span> exynos_sromc *)(EXYNOS4412_SROMC_BASE);</span><br><span class="line"></span><br><span class="line">	<span class="comment">/* Configure SMC_BW register to handle proper SROMC bank */</span></span><br><span class="line">	tmp = srom-&gt;bw;</span><br><span class="line">	tmp &amp;= ~(<span class="number">0xF</span> &lt;&lt; (srom_bank * <span class="number">4</span>));</span><br><span class="line">	tmp |= srom_bw_conf;</span><br><span class="line">	srom-&gt;bw = tmp;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/* Configure SMC_BC register */</span></span><br><span class="line">	srom-&gt;bc[srom_bank] = srom_bc_conf;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">static</span> <span class="type">void</span> <span class="title function_">dm9000aep_pre_init</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">int</span> tmp;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">char</span> smc_bank_num = <span class="number">1</span>;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">int</span>     smc_bw_conf=<span class="number">0</span>;</span><br><span class="line">	<span class="type">unsigned</span> <span class="type">int</span>     smc_bc_conf=<span class="number">0</span>;</span><br><span class="line">       </span><br><span class="line">	<span class="comment">/* gpio configuration */</span></span><br><span class="line">	writel(<span class="number">0x00220020</span>, <span class="number">0x11000000</span> + <span class="number">0x120</span>);</span><br><span class="line">	writel(<span class="number">0x00002222</span>, <span class="number">0x11000000</span> + <span class="number">0x140</span>);</span><br><span class="line">	<span class="comment">/* 16 Bit bus width */</span></span><br><span class="line">	writel(<span class="number">0x22222222</span>, <span class="number">0x11000000</span> + <span class="number">0x180</span>);</span><br><span class="line">	writel(<span class="number">0x0000FFFF</span>, <span class="number">0x11000000</span> + <span class="number">0x188</span>);</span><br><span class="line">	writel(<span class="number">0x22222222</span>, <span class="number">0x11000000</span> + <span class="number">0x1C0</span>);</span><br><span class="line">	writel(<span class="number">0x0000FFFF</span>, <span class="number">0x11000000</span> + <span class="number">0x1C8</span>);</span><br><span class="line">	writel(<span class="number">0x22222222</span>, <span class="number">0x11000000</span> + <span class="number">0x1E0</span>);</span><br><span class="line">	writel(<span class="number">0x0000FFFF</span>, <span class="number">0x11000000</span> + <span class="number">0x1E8</span>);              </span><br><span class="line">	smc_bw_conf &amp;= ~(<span class="number">0xf</span>&lt;&lt;<span class="number">4</span>);</span><br><span class="line">	smc_bw_conf |= (<span class="number">1</span>&lt;&lt;<span class="number">7</span>) | (<span class="number">1</span>&lt;&lt;<span class="number">6</span>) | (<span class="number">1</span>&lt;&lt;<span class="number">5</span>) | (<span class="number">1</span>&lt;&lt;<span class="number">4</span>);</span><br><span class="line">	smc_bc_conf = ((DM9000_Tacs &lt;&lt; <span class="number">28</span>)</span><br><span class="line">				 | (DM9000_Tcos &lt;&lt; <span class="number">24</span>)</span><br><span class="line">				 | (DM9000_Tacc &lt;&lt; <span class="number">16</span>)</span><br><span class="line">				 | (DM9000_Tcoh &lt;&lt; <span class="number">12</span>)</span><br><span class="line">				 | (DM9000_Tah  &lt;&lt; <span class="number">8</span>)</span><br><span class="line">				 | (DM9000_Tacp &lt;&lt; <span class="number">4</span>)</span><br><span class="line">				 | (DM9000_PMC));</span><br><span class="line">	exynos_config_sromc(smc_bank_num,smc_bw_conf,smc_bc_conf);</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<p>（2）我们再找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">gd-&gt;bd-&gt;bi_boot_params = (PHYS_SDRAM_1 + <span class="number">0x100</span>UL);</span><br></pre></td></tr></table></figure>

<p>在语句后边添加以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_DRIVER_DM9000</span></span><br><span class="line">	dm9000aep_pre_init();</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<p>（3）在整个文件尾部添加如下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_CMD_NET</span></span><br><span class="line"><span class="type">int</span> <span class="title function_">board_eth_init</span><span class="params">(<span class="type">bd_t</span> *bis)</span>                                                  </span><br><span class="line">&#123;      </span><br><span class="line">	<span class="type">int</span> rc = <span class="number">0</span>;</span><br><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_DRIVER_DM9000</span></span><br><span class="line">	rc = dm9000_initialize(bis);                                            </span><br><span class="line"><span class="meta">#<span class="keyword">endif</span>                                                                         </span></span><br><span class="line">	<span class="keyword">return</span> rc;                                                              </span><br><span class="line">&#125;  </span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<h4 id="5-1-2-网络配置修改"><a href="#5-1-2-网络配置修改" class="headerlink" title="5.1.2 网络配置修改"></a><font size=3>5.1.2 网络配置修改</font></h4><ul>
<li>修改<code>include/configs/fs4412.h</code>文件</li>
</ul>
<p>（1）我们找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">undef</span> CONFIG_CMD_PING</span></span><br></pre></td></tr></table></figure>

<p>将其修改为如下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_CMD_PING</span></span><br></pre></td></tr></table></figure>

<p>（2）我们找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">undef</span> CONFIG_CMD_NET</span></span><br></pre></td></tr></table></figure>

<p>将其修改为如下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_CMD_NET</span></span><br></pre></td></tr></table></figure>

<p>（3）我们找到如下语句（也就是文件末尾）：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">endif</span>	<span class="comment">/* __CONFIG_H */</span></span></span><br></pre></td></tr></table></figure>

<p>在其前边添加以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span>  CONFIG_CMD_NET</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_NET_MULTI</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_DRIVER_DM9000	1</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_DM9000_BASE	0x05000000</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_IO	CONFIG_DM9000_BASE</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> DM9000_DATA	(CONFIG_DM9000_BASE + 4)</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_DM9000_USE_16BIT</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_DM9000_NO_SROM	1</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_ETHADDR	 11:22:33:44:55:66</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_IPADDR	 192.168.10.102</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_SERVERIP	 192.168.10.101</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_GATEWAYIP 192.168.10.1</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_NETMASK	 255.255.255.0</span></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<h3 id="5-2-编译u-boot"><a href="#5-2-编译u-boot" class="headerlink" title="5.2 编译u-boot"></a><font size=3>5.2 编译<code>u-boot</code></font></h3><p>我们直接通过编译脚本进行编译：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./qidaink_make.sh</span><br></pre></td></tr></table></figure>

<p>编译完成后将生成的<code>u-boot-fs4412.bin</code>制作成可在开发板运行的镜像，下载到<code>SD</code>卡进行测试，我们再<code>SecureCRT</code>中执行以下命令：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">fs4412 # ping 192.168.10.101</span><br><span class="line">fs4412 # ping 192.168.10.100</span><br></pre></td></tr></table></figure>

<p>若有以下提示，则证明网卡移植成功：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821113347024.png" alt="image-20220821113347024" style="zoom:33%;" />

<h2 id="6-eMMC移植"><a href="#6-eMMC移植" class="headerlink" title="6. eMMC移植"></a><font size=3>6. <code>eMMC</code>移植</font></h2><p>我们在启动开发板的时候，会看到这样的提示：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MMC:   SAMSUNG SDHCI: 0</span><br></pre></td></tr></table></figure>

<p>若是这里<code>eMMC</code>可以正常读取的话，这里应该是会显示容量大小，而不是这样显示，所以我这里我们还需要对<code>eMMC</code>进行移植。详细的文件更改情况可以查看这里：<a target="_blank" rel="noopener" href="https://github.com/sumumm/u-boot/commit/e747fb7d43fe0fa9971495938485c720d5834f0c">feat:修改eMMC驱动 · sumumm&#x2F;u-boot@e747fb7 (github.com)</a></p>
<h3 id="6-1-文件准备"><a href="#6-1-文件准备" class="headerlink" title="6.1 文件准备"></a><font size=3>6.1 文件准备</font></h3><p>这里我们需要准备一些相关的移植文件到工程中：</p>
<ul>
<li><code>arch/arm/cpu/armv7/exynos/</code></li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/movi.c arch/arm/cpu/armv7/exynos/</span><br></pre></td></tr></table></figure>

<ul>
<li><code>common/</code></li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/cmd_movi.c common/</span><br><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/cmd_mmc.c common/</span><br><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/cmd_mmc_fdisk.c common/</span><br></pre></td></tr></table></figure>

<ul>
<li><code>drivers/mmc/</code></li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/mmc.c drivers/mmc/</span><br><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/s5p_mshc.c drivers/mmc/</span><br></pre></td></tr></table></figure>

<ul>
<li><code>include/</code></li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/mmc.h include/</span><br><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/movi.h include/</span><br><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/s5p_mshc.h include/</span><br></pre></td></tr></table></figure>

<h3 id="6-2-修改相关文件"><a href="#6-2-修改相关文件" class="headerlink" title="6.2 修改相关文件"></a><font size=3>6.2 修改相关文件</font></h3><h4 id="6-2-1-eMMC初始化"><a href="#6-2-1-eMMC初始化" class="headerlink" title="6.2.1 eMMC初始化"></a><font size=3>6.2.1 <code>eMMC</code>初始化</font></h4><ul>
<li><code>arch/arm/cpu/armv7/exynos/Makefile</code></li>
</ul>
<p>我们将<code>movi.c</code>拷贝到了<code>u-boot</code>源码的<code>arch/arm/cpu/armv7/exynos/</code>目录下，添加的新文件也要编译，所以对应的<code>Makefile</code>也要修改。</p>
<p>我们找到如下语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS	+= clock.o power.o soc.o system.o pinmux.o</span><br></pre></td></tr></table></figure>

<p>将其修改为以下内容：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS	+= clock.o power.o soc.o system.o pinmux.o movi.o</span><br></pre></td></tr></table></figure>



<ul>
<li>修改板级文件<code>board/samsung/fs4412/fs4412.c</code></li>
</ul>
<p>（1）我们找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;asm/arch/mmc.h&gt;</span></span></span><br></pre></td></tr></table></figure>

<p>在语句后边添加以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;asm/arch/clk.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;origen_setup.h&quot;</span></span></span><br></pre></td></tr></table></figure>

<p>（2）我们再找到如下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_GENERIC_MMC</span></span><br></pre></td></tr></table></figure>

<p>然后在该语句后边添加如下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><span class="line">u32 sclk_mmc4;  <span class="comment">/*clock source for emmc controller*/</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> __REGMY(x) (*((volatile u32 *)(x)))</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CLK_SRC_FSYS  __REGMY(EXYNOS4_CLOCK_BASE + CLK_SRC_FSYS_OFFSET)</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> CLK_DIV_FSYS3 __REGMY(EXYNOS4_CLOCK_BASE + CLK_DIV_FSYS3_OFFSET)</span></span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">emmc_init</span><span class="params">()</span></span><br><span class="line">&#123;</span><br><span class="line">	u32 tmp;</span><br><span class="line">	u32 clock;</span><br><span class="line">	u32 i;</span><br><span class="line">	<span class="comment">/* setup_hsmmc_clock */</span></span><br><span class="line">	<span class="comment">/* MMC4 clock src = SCLKMPLL */</span></span><br><span class="line">	tmp = CLK_SRC_FSYS &amp; ~(<span class="number">0x000f0000</span>);</span><br><span class="line">	CLK_SRC_FSYS = tmp | <span class="number">0x00060000</span>;</span><br><span class="line">	<span class="comment">/* MMC4 clock div */</span></span><br><span class="line">	tmp = CLK_DIV_FSYS3 &amp; ~(<span class="number">0x0000ff0f</span>);</span><br><span class="line">	clock = get_pll_clk(MPLL)/<span class="number">1000000</span>;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">for</span>(i=<span class="number">0</span> ; i&lt;=<span class="number">0xf</span>; i++)  &#123;</span><br><span class="line">		sclk_mmc4=(clock/(i+<span class="number">1</span>));</span><br><span class="line"></span><br><span class="line">		<span class="keyword">if</span>(sclk_mmc4 &lt;= <span class="number">160</span>) <span class="comment">//200</span></span><br><span class="line">		&#123;</span><br><span class="line">			CLK_DIV_FSYS3 = tmp | (i&lt;&lt;<span class="number">0</span>);</span><br><span class="line">			<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	emmcdbg(<span class="string">&quot;[mjdbg] sclk_mmc4:%d MHZ; mmc_ratio: %d\n&quot;</span>,sclk_mmc4,i);</span><br><span class="line">	sclk_mmc4 *= <span class="number">1000000</span>;</span><br><span class="line"></span><br><span class="line">	<span class="comment">/*</span></span><br><span class="line"><span class="comment">	* MMC4 EMMC GPIO CONFIG</span></span><br><span class="line"><span class="comment">	*</span></span><br><span class="line"><span class="comment">	* GPK0[0]	SD_4_CLK</span></span><br><span class="line"><span class="comment">	* GPK0[1]	SD_4_CMD</span></span><br><span class="line"><span class="comment">	* GPK0[2]	SD_4_CDn</span></span><br><span class="line"><span class="comment">	* GPK0[3:6]	SD_4_DATA[0:3]</span></span><br><span class="line"><span class="comment">	*/</span></span><br><span class="line">	writel(readl(<span class="number">0x11000048</span>)&amp;~(<span class="number">0xf</span>),<span class="number">0x11000048</span>); <span class="comment">//SD_4_CLK/SD_4_CMD pull-down enable</span></span><br><span class="line">	writel(readl(<span class="number">0x11000040</span>)&amp;~(<span class="number">0xff</span>),<span class="number">0x11000040</span>);<span class="comment">//cdn set to be output</span></span><br><span class="line"></span><br><span class="line">	writel(readl(<span class="number">0x11000048</span>)&amp;~(<span class="number">3</span>&lt;&lt;<span class="number">4</span>),<span class="number">0x11000048</span>); <span class="comment">//cdn pull-down disable</span></span><br><span class="line">	writel(readl(<span class="number">0x11000044</span>)&amp;~(<span class="number">1</span>&lt;&lt;<span class="number">2</span>),<span class="number">0x11000044</span>); <span class="comment">//cdn output 0 to shutdown the emmc power</span></span><br><span class="line">	writel(readl(<span class="number">0x11000040</span>)&amp;~(<span class="number">0xf</span>&lt;&lt;<span class="number">8</span>)|(<span class="number">1</span>&lt;&lt;<span class="number">8</span>),<span class="number">0x11000040</span>);<span class="comment">//cdn set to be output</span></span><br><span class="line">	udelay(<span class="number">100</span>*<span class="number">1000</span>);</span><br><span class="line">	writel(readl(<span class="number">0x11000044</span>)|(<span class="number">1</span>&lt;&lt;<span class="number">2</span>),<span class="number">0x11000044</span>); <span class="comment">//cdn output 1</span></span><br><span class="line"></span><br><span class="line">	writel(<span class="number">0x03333133</span>, <span class="number">0x11000040</span>);</span><br><span class="line"></span><br><span class="line">	writel(<span class="number">0x00003FF0</span>, <span class="number">0x11000048</span>);</span><br><span class="line">	writel(<span class="number">0x00002AAA</span>, <span class="number">0x1100004C</span>);</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_EMMC_8Bit</span></span><br><span class="line">	writel(<span class="number">0x04444000</span>, <span class="number">0x11000060</span>);</span><br><span class="line">	writel(<span class="number">0x00003FC0</span>, <span class="number">0x11000068</span>);</span><br><span class="line">	writel(<span class="number">0x00002AAA</span>, <span class="number">0x1100006C</span>);</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">ifdef</span> USE_MMC4</span></span><br><span class="line">	smdk_s5p_mshc_init();</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span> </span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>（3）我们找到<code>board_mmc_init</code>函数，并将函数体内原来的代码删掉，修改为以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span> <span class="title function_">board_mmc_init</span><span class="params">(<span class="type">bd_t</span> *bis)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="type">int</span> i, err;</span><br><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_EMMC</span></span><br><span class="line">	err = emmc_init();</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br><span class="line">	<span class="keyword">return</span> err;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>（4）我们在文件末尾添加以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_BOARD_LATE_INIT</span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;movi.h&gt;</span></span></span><br><span class="line"><span class="type">int</span>  <span class="title function_">chk_bootdev</span><span class="params">(<span class="type">void</span>)</span><span class="comment">//mj for boot device check</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="type">char</span> run_cmd[<span class="number">100</span>];</span><br><span class="line">	<span class="class"><span class="keyword">struct</span> <span class="title">mmc</span> *<span class="title">mmc</span>;</span></span><br><span class="line">	<span class="type">int</span> boot_dev = <span class="number">0</span>;</span><br><span class="line">	<span class="type">int</span> cmp_off = <span class="number">0x10</span>;</span><br><span class="line">	ulong  start_blk, blkcnt;</span><br><span class="line"></span><br><span class="line">	mmc = find_mmc_device(<span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">if</span> (mmc == <span class="literal">NULL</span>)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;There is no eMMC card, Booting device is SD card\n&quot;</span>);</span><br><span class="line">		boot_dev = <span class="number">1</span>;</span><br><span class="line">		<span class="keyword">return</span> boot_dev;</span><br><span class="line"> 	&#125;</span><br><span class="line">	start_blk = (<span class="number">24</span>*<span class="number">1024</span>/MOVI_BLKSIZE);</span><br><span class="line">	blkcnt = <span class="number">0x10</span>;</span><br><span class="line"></span><br><span class="line">	<span class="built_in">sprintf</span>(run_cmd,<span class="string">&quot;emmc open 0&quot;</span>);</span><br><span class="line">	run_command(run_cmd, <span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">	<span class="built_in">sprintf</span>(run_cmd,<span class="string">&quot;mmc read 0 %lx %lx %lx&quot;</span>,CFG_PHY_KERNEL_BASE,start_blk,blkcnt);</span><br><span class="line">	run_command(run_cmd, <span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">	<span class="comment">/* switch mmc to normal paritition */</span></span><br><span class="line">	<span class="built_in">sprintf</span>(run_cmd,<span class="string">&quot;emmc close 0&quot;</span>);</span><br><span class="line">	run_command(run_cmd, <span class="number">0</span>);</span><br><span class="line"></span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">board_late_init</span> <span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="type">int</span> boot_dev =<span class="number">0</span> ;</span><br><span class="line">	<span class="type">char</span> boot_cmd[<span class="number">100</span>];</span><br><span class="line">	boot_dev = chk_bootdev();</span><br><span class="line">	<span class="keyword">if</span>(!boot_dev)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\n\nChecking Boot Mode ... EMMC4.41\n&quot;</span>);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<h4 id="6-2-2-添加eMMC命令"><a href="#6-2-2-添加eMMC命令" class="headerlink" title="6.2.2 添加eMMC命令"></a><font size=3>6.2.2 添加<code>eMMC</code>命令</font></h4><ul>
<li><code>common/Makefile</code></li>
</ul>
<p>我们拷贝了<code>cmd_movi.c</code>、<code>cmd_mmc.c</code>、<code>cmd_mmc_fdisk.c</code>拷贝到<code>u-boot</code> 源码的<code>common/</code>目录下，新添加的文件需要参加编译，需要修改对应的<code>Makefile</code>：</p>
<p>我们找到如下语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS-<span class="variable">$(CONFIG_CMD_MMC)</span> += cmd_mmc.o</span><br></pre></td></tr></table></figure>

<p>在语句后边添加以下内容：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">COBJS-<span class="variable">$(CONFIG_CMD_MMC)</span> += cmd_mmc_fdisk.o</span><br><span class="line">COBJS-<span class="variable">$(CONFIG_CMD_MOVINAND)</span> += cmd_movi.o</span><br></pre></td></tr></table></figure>

<ul>
<li><code>drivers/mmc/Makefile </code></li>
</ul>
<p>我们前边还拷贝了<code>mmc.c</code>、<code>s5p_mshc.c</code>拷贝到<code>u-boot</code>源码的<code>drivers/mmc/</code>目录下，所以对应的<code>Makefile</code>需要修改。</p>
<p>我们找到如下语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS-<span class="variable">$(CONFIG_S5P_SDHCI)</span> += s5p_sdhci.o</span><br></pre></td></tr></table></figure>

<p>在后边添加以下内容：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS-<span class="variable">$(CONFIG_S5P_MSHC)</span> += s5p_mshc.o</span><br></pre></td></tr></table></figure>

<h4 id="6-2-3-eMMC配置"><a href="#6-2-3-eMMC配置" class="headerlink" title="6.2.3 eMMC配置"></a><font size=3>6.2.3 <code>eMMC</code>配置</font></h4><ul>
<li><code>include/configs/fs4412.h</code></li>
</ul>
<p>我们找到如下语句，也就是文件末尾：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">endif	/* __CONFIG_H */</span></span><br></pre></td></tr></table></figure>

<p>在前边添加以下内容：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_EVT1     1       /* EVT1 */</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ifdef CONFIG_EVT1</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_EMMC44_CH4 //eMMC44_CH4 (OMPIN[5:1] = 4)</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ifdef CONFIG_SDMMC_CH2</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_S3C_HSMMC</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">undef DEBUG_S3C_HSMMC</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define USE_MMC2</span>  </span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">endif</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">ifdef CONFIG_EMMC44_CH4</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_S5P_MSHC</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_EMMC             1</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define USE_MMC4</span>  </span><br><span class="line">/* #define CONFIG_EMMC_8Bit */</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_EMMC_EMERGENCY</span></span><br><span class="line">/*#define emmcdbg(fmt,args...) printf(fmt ,##args) */</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define emmcdbg(<span class="built_in">fmt</span>,args...)</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">endif</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">endif /*end CONFIG_EVT1*/</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_CMD_MOVINAND</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_CLK_1000_400_200</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CFG_PHY_UBOOT_BASE      CONFIG_SYS_SDRAM_BASE + 0x3e00000</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CFG_PHY_KERNEL_BASE     CONFIG_SYS_SDRAM_BASE + 0x8000</span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define BOOT_MMCSD      0x3</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define BOOT_EMMC43     0x6</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define BOOT_EMMC441    0x7</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">define CONFIG_BOARD_LATE_INIT</span></span><br></pre></td></tr></table></figure>

<h3 id="6-3-编译u-boot"><a href="#6-3-编译u-boot" class="headerlink" title="6.3 编译u-boot"></a><font size=3>6.3 编译<code>u-boot</code></font></h3><p>我们直接通过编译脚本进行编译：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./qidaink_make.sh</span><br></pre></td></tr></table></figure>

<p>编译完成后将生成的<code>u-boot-fs4412.bin</code>制作成可在开发板运行的镜像，下载到<code>SD</code>卡进行测试，若有如下提示，则证明<code>eMMC</code>移植成功：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821120100177.png" alt="image-20220821120100177" style="zoom:33%;" />

<h2 id="7-电源管理移植"><a href="#7-电源管理移植" class="headerlink" title="7. 电源管理移植"></a><font size=3>7. 电源管理移植</font></h2><p><code>u-boot</code>源码中对电源管理芯片的配置与<code>fs4412</code>板子不匹配，后续有可能会导致内核启动卡死，这里还需要对电源管理芯片相关的代码进行修改和配置。详细的文件修改可以看这里：<a target="_blank" rel="noopener" href="https://github.com/sumumm/u-boot/commit/98cb6393179d370f035e03b323f331a10f2ed281">feat:修改电源管理驱动 · sumumm&#x2F;u-boot@98cb639 (github.com)</a></p>
<h3 id="7-1-文件准备"><a href="#7-1-文件准备" class="headerlink" title="7.1 文件准备"></a><font size=3>7.1 文件准备</font></h3><p>这里我们需要准备一些相关的移植文件到工程中：</p>
<ul>
<li><code>drivers/power/pmic/</code></li>
</ul>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mv /mnt/hgfs/Sharedfiles/test/u-boot-2013.01移植相关文件/movi.c arch/arm/cpu/armv7/exynos/</span><br></pre></td></tr></table></figure>

<h3 id="7-2-修改相关文件"><a href="#7-2-修改相关文件" class="headerlink" title="7.2 修改相关文件"></a><font size=3>7.2 修改相关文件</font></h3><ul>
<li><code>drivers/power/pmic/Makefile</code></li>
</ul>
<p>我们拷贝了<code>pmic_s5m8767.c</code>到<code>u-boot</code>源码的<code>drivers/power/pmic/</code>目录下，新文件需要参与编译，所以需要修改<code>Makefile</code>。</p>
<p>我们找到如下语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS-<span class="variable">$(CONFIG_POWER_MAX77686)</span> += pmic_max77686.o</span><br></pre></td></tr></table></figure>

<p>然后在该语句后边添加以下内容：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS-<span class="variable">$(CONFIG_POWER_S5M8767)</span> += pmic_s5m8767.o</span><br></pre></td></tr></table></figure>

<ul>
<li><code>include/power/pmic.h</code></li>
</ul>
<p>我们还需要将添加的函数在相关的头文件中进行声明，我们找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">int</span> <span class="title function_">pmic_set_output</span><span class="params">(<span class="keyword">struct</span> pmic *p, u32 reg, <span class="type">int</span> ldo, <span class="type">int</span> on)</span>;</span><br></pre></td></tr></table></figure>

<p>在该语句后添加如下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="type">void</span> <span class="title function_">pmic_s5m8767_init</span><span class="params">(<span class="type">void</span>)</span>;</span><br></pre></td></tr></table></figure>

<ul>
<li>修改配置文件<code>include/configs/fs4412.h</code></li>
</ul>
<p>我们找到如下语句，也就是文件末尾：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">endif</span>	<span class="comment">/* __CONFIG_H */</span></span></span><br></pre></td></tr></table></figure>

<p>我们在该语句前边添加以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">define</span> CONFIG_POWER_S5M8767</span></span><br></pre></td></tr></table></figure>

<ul>
<li>修改板级文件<code>board/samsung/fs4412/fs4412.c</code></li>
</ul>
<p>我们找到<code>board_init</code>函数的如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_DRIVER_DM9000</span></span><br><span class="line">	dm9000aep_pre_init();</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<p>我们在最后一句后边添加以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_POWER_S5M8767</span></span><br><span class="line">	pmic_s5m8767_init();</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<ul>
<li><code>drivers/power/Makefile</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">COBJS-<span class="variable">$(CONFIG_POWER)</span> += power_core.o</span><br></pre></td></tr></table></figure>

<p>然后将该语句修改为：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># COBJS-$(CONFIG_POWER) += power_core.o</span></span><br></pre></td></tr></table></figure>

<ul>
<li>修改架构文件<code>arch/arm/cpu/armv7/s5p-common/cpu_info.c</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;asm/arch/clk.h&gt;</span></span></span><br></pre></td></tr></table></figure>

<p>在该语句后添加以下内容：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;power/pmic.h&gt;</span></span></span><br></pre></td></tr></table></figure>

<h3 id="7-3-编译u-boot"><a href="#7-3-编译u-boot" class="headerlink" title="7.3 编译u-boot"></a><font size=3>7.3 编译<code>u-boot</code></font></h3><p>我们直接通过编译脚本进行编译：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./qidaink_make.sh</span><br></pre></td></tr></table></figure>

<p>编译完成后将生成的<code>u-boot-fs4412.bin</code>制作成可在开发板运行的镜像，下载到<code>SD</code>卡进行测试，若有如下提示（我记得在移植之前是不显示这个的），则证明电源管理移植成功：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV09-uboot%E4%B8%8Elinux/LV09-02-uboot-03-uboot%E7%A7%BB%E6%A4%8D/img/image-20220821121614931.png" alt="image-20220821121614931" style="zoom:33%;" />

<h1 id="三、其他修改"><a href="#三、其他修改" class="headerlink" title="三、其他修改"></a><font size=3>三、其他修改</font></h1><h2 id="1-编译脚本"><a href="#1-编译脚本" class="headerlink" title="1. 编译脚本"></a><font size=3>1. 编译脚本</font></h2><p>编译完<code>u-boot</code>后，需要生成可在开发板裸机运行的镜像文件，我们可以咋子编译脚本中进行修改，这样我们执行脚本就可以生成相应的镜像文件吗，而不需要再输入那么长一段命令了。</p>
<details class="folding-tag" blue><summary> 点击查看修改后的编译脚本 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">!/bin/sh</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">=====================================================</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Copyright © hk. 2022-2025. All rights reserved.</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">File name: qidaink_make.sh</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Author   : qidaink</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Date     : 2022-08-19</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Version  :</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Description:</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Others   : CROSS_COMPILE -- 当前使用的编译器</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Log      :</span> </span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">======================================================</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash"><span class="comment">#</span></span></span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">===================相关参数定义=========================</span></span><br><span class="line">CPU_JOB_NUM=$(grep processor /proc/cpuinfo | awk &#x27;&#123;field=$NF&#125;;END&#123;print field+1&#125;&#x27;) # 参与编译的内核数量获取</span><br><span class="line">BOARD_NAME=&quot;fs4412&quot;                                         # 硬件平台,后续以 origen 评估板为模板</span><br><span class="line">MAKE_PARAM=&quot;ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-&quot; # 交叉编译器</span><br><span class="line">sec_path=&quot;CodeSign4SecureBoot/&quot;                          # 三星加密引导方式路径</span><br><span class="line">ROOT_DIR=$(pwd)                                          # 顶层(当前)目录路径</span><br><span class="line">CUR_DIR=$&#123;ROOT_DIR##*/&#125;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">===================配置与编译===========================</span></span><br><span class="line">case &quot;$1&quot; in</span><br><span class="line">	clean)</span><br><span class="line">                # 清除编译过程中产生的中间文件而不清除加密文件</span><br><span class="line">                echo</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m[INFO ]make $&#123;MAKE_PARAM&#125; clean                 \033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot; </span><br><span class="line">                make $&#123;MAKE_PARAM&#125; mrproper</span><br><span class="line">                ;;</span><br><span class="line">        image)</span><br><span class="line">                # 制作镜像文件</span><br><span class="line">                echo</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m[INFO ]Creating an Image File...                \033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot; </span><br><span class="line">                sudo dd if=/dev/zero of=zero.bin count=1     # 制作一个512Bytes的空镜像</span><br><span class="line">                sudo dd if=/dev/zero of=clear.bin count=2048 # 制作一个1M的空镜像</span><br><span class="line">                # 判断 u-boot-fs4412.bin 文件是否存在</span><br><span class="line">                if [ ! -e u-boot-fs4412.bin ]</span><br><span class="line">                        then</span><br><span class="line">                        echo</span><br><span class="line">                        echo &quot;\033[1;31m************************************************\033[0m&quot;</span><br><span class="line">                        echo &quot;\033[1;31m[ERROR]please get the u-boot-fs4412.bin first!  \033[0m&quot;</span><br><span class="line">                        echo &quot;\033[1;31m************************************************\033[0m&quot;</span><br><span class="line">                        return</span><br><span class="line">                        fi</span><br><span class="line">                cat zero.bin u-boot-fs4412.bin &gt; win-u-boot-fs4412.bin</span><br><span class="line">                echo</span><br><span class="line">                echo &quot;\033[1;32m************************************************\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;32m[INFO ]Image finished!!!                        \033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;32m************************************************\033[0m&quot; </span><br><span class="line">                ;;</span><br><span class="line">	*)</span><br><span class="line">                # 判断加密引导方式文件目录是否存在</span><br><span class="line">                if [ ! -d $&#123;sec_path&#125; ]</span><br><span class="line">                        then</span><br><span class="line">                        echo</span><br><span class="line">                        echo &quot;\033[1;31m************************************************\033[0m&quot;</span><br><span class="line">                        echo &quot;\033[1;31m[ERROR]please get the CodeSign4SecureBoot first!\033[0m&quot;</span><br><span class="line">                        echo &quot;\033[1;31m************************************************\033[0m&quot;</span><br><span class="line">                        return</span><br><span class="line">                        fi</span><br><span class="line"></span><br><span class="line">                # 指定当前使用的硬件平台 make &lt;BOARD_NAME&gt;_config</span><br><span class="line">                echo</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m[INFO ]Configuring the Project ...              \033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">                make $&#123;MAKE_PARAM&#125; $&#123;BOARD_NAME&#125;_config</span><br><span class="line"></span><br><span class="line">                # 开始编译整个 uboot</span><br><span class="line">                echo</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m[INFO ]Building project in progress ...         \033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;33m************************************************\033[0m&quot;</span><br><span class="line">                make V=1 $&#123;MAKE_PARAM&#125; -j$&#123;CPU_JOB_NUM&#125;</span><br><span class="line"></span><br><span class="line">                # 判断是否编译成功</span><br><span class="line">                if [ ! -f checksum_bl2_14k.bin ]</span><br><span class="line">                        then</span><br><span class="line">                        echo</span><br><span class="line">                        echo &quot;\033[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\033[0m&quot;</span><br><span class="line">                        echo &quot;\033[1;31m[ERROR]There are some error(s) while building uboot, please use command make to check.\033[0m&quot;</span><br><span class="line">                        echo &quot;\033[1;31m!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\033[0m&quot;</span><br><span class="line">                        exit 0</span><br><span class="line">                        fi</span><br><span class="line">                # 三星加密引导方式相关操作，必须要有</span><br><span class="line">                cp -rf checksum_bl2_14k.bin $&#123;sec_path&#125;</span><br><span class="line">                cp -rf u-boot.bin $&#123;sec_path&#125;</span><br><span class="line">                rm checksum_bl2_14k.bin</span><br><span class="line"></span><br><span class="line">                cd $&#123;sec_path&#125;</span><br><span class="line">                cat E4412_N.bl1.SCP2G.bin bl2.bin all00_padding.bin u-boot.bin tzsw_SMDK4412_SCP_2GB.bin &gt; u-boot-fs4412.bin</span><br><span class="line">                mv u-boot-fs4412.bin $&#123;ROOT_DIR&#125;</span><br><span class="line">                </span><br><span class="line">                rm checksum_bl2_14k.bin</span><br><span class="line">                rm u-boot.bin</span><br><span class="line"></span><br><span class="line">                # 编译完成提示已经完成</span><br><span class="line">                echo</span><br><span class="line">                echo &quot;\033[1;32m************************************************\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;32m[INFO ]The compilation is complete!!!\033[0m&quot;</span><br><span class="line">                echo &quot;\033[1;32m************************************************\033[0m&quot;</span><br><span class="line">                echo </span><br><span class="line">                ;;</span><br><span class="line">esac</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<p>这样，我们每次编译完毕后，可以在终端执行：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./qidaink_make.sh image</span><br></pre></td></tr></table></figure>

<p>这样便会生成我们需要的<code>win-u-boot-fs4412.bin</code>文件啦。</p>
<h2 id="2-板子名称"><a href="#2-板子名称" class="headerlink" title="2. 板子名称"></a><font size=3>2. 板子名称</font></h2><p>我们上边已经将<code>u-boot</code>进行移植，移植到了我们使用的<code>fs4412</code>板子上，但是打印出来的提示信息中板子名称依然是原来的，如何修改呢？</p>
<ul>
<li><code>board/samsung/fs4412/fs4412.c</code></li>
</ul>
<p>我们找到如下语句：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifdef</span> CONFIG_DISPLAY_BOARDINFO</span></span><br><span class="line"><span class="type">int</span> <span class="title function_">checkboard</span><span class="params">(<span class="type">void</span>)</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;\nBoard: ORIGEN\n&quot;</span>);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure>

<p>这个函数就是打印输出板子名称的，我们在这里将其修改为自己想要的板子名称就可以啦。</p>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/9d24e334.html">LV09-02-uboot-03-uboot移植</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年07月07日 - 19:34</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/9d24e334.html" title="LV09-02-uboot-03-uboot移植">https://sumumm.github.io/post/9d24e334.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV09-uboot%E4%B8%8Elinux/" rel="tag"><i class="fa fa-tag"></i> LV09-uboot与linux</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/1234bbb.html" rel="prev" title="LV09-03-linux-01-内核加载">
                  <i class="fa fa-angle-left"></i> LV09-03-linux-01-内核加载
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/41a25a19.html" rel="next" title="LV09-02-uboot-02-命令简介">
                  LV09-02-uboot-02-命令简介 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
